//


#import "AM_SettingTableViewCell.h"

@implementation AM_SettingTableViewCell

// 初始化cell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self createTableViewCell];
    }
    return self;
}

// 初始化
-(void)createTableViewCell {
    //
    self.titleLabel = ({
        UILabel *label = [[UILabel alloc]init];
        label.textColor = rgba(60, 60, 60, 1);
        label.font = FontPFRegular(kRelativeWidth(16));
        label.text = @"";
        [self.contentView addSubview:label];
        label;
    });
    //
    self.detailLabel = ({
        UILabel *label = [[UILabel alloc]init];
        label.textColor = rgba(90, 90, 90, 1);
        label.font = FontPFRegular(kRelativeWidth(15));
        label.text = @"Memorandum is a product that records account number. It is portable, simple and convenient for unified management.";
        label.numberOfLines = 0;
        [self.contentView addSubview:label];
        label;
    });
    //
    self.arrowButton = ({
        UIButton *button = [[UIButton alloc]init];
        [button setImage:[UIImage imageNamed:@"arrows-up"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"arrow-down"] forState:UIControlStateSelected];
        [button addTarget:self action:@selector(Action:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:button];
        button;
    });
    
}

- (void)setNeedsLayout {
    [super setNeedsLayout];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(kRelativeHeight(15));
        make.left.mas_offset(kRelativeWidth(15));
        make.height.mas_equalTo(kRelativeHeight(20));
    }];
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(kRelativeHeight(10));
        make.left.mas_offset(kRelativeWidth(15));
        make.width.mas_equalTo(kMainScreenWidth - kRelativeWidth(30));
    }];
    [self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(kRelativeHeight(15));
        make.right.mas_offset(-kRelativeWidth(15));
        make.width.mas_equalTo(kRelativeWidth(12));
        make.height.mas_equalTo(kRelativeHeight(20));
    }];
}

//
- (void)Action:(UIButton*)button {
    if ([self.delegate respondsToSelector:@selector(setCellButton:)]) {
        [self.delegate setCellButton:button];
    }
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
